package com.shopping.service.impl;

import com.shopping.mapper.UserMapper;
import com.shopping.model.UserInfo;
import com.shopping.service.UserService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImp implements UserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public void register(UserInfo userInfo) throws Exception{
        //对密码进行加密
        BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
        String encode = bCryptPasswordEncoder.encode(userInfo.getUser_password());
        userInfo.setUser_password(encode);
        userMapper.register(userInfo);
    }
}
